---
id: MqttClient
title: MqttClient
sidebar_label: 7.2、MqttClient
---


### （一）设备配置

| 属性           |  说明                    | 默认值/备注|
| ---------------| --------------------------| ---|
| 连接Id         | 连接Id  |ThingsGatewayId|
| 账号         | 登录账号              | admin|
| 密码         | 登录密码              | 123456|
| IP         | 连接IP              | 127.0.0.1|
| 端口         | 连接端口              | 1883|
| 连接超时         | 连接超时时间              | 3000|
| 允许Rpc写入         | 是否允许写入变量              | True |
| 数据请求RpcTopic         | 该主题接受到任何消息都会发布全部信息到对应的设备/变量主题中              | ThingsGateway/Quest |
| Rpc写入Topic         | 写入变量的发布Topic              | ThingsGateway/RpcWrite |
| Rpc返回Topic         | 写入变量的订阅Topic，返回写入结果信息              | ThingsGateway/RpcSub |
| 变量Topic         | 变量信息订阅Topic              | ThingsGateway/Variable |
| 设备Topic         | 设备信息订阅Topic              | ThingsGateway/Device |

RpcJson：
```
{
  "Name":"tt8",//变量名称
  "Value":"12421",//变量值
  "RpcId":"testid"//当前RpcId
}
```
Rpc返回Json：
```
{
  "RpcId":"testid", //RpcId
  "Message":"操作成功",//返回消息
  "Success":true//是否成功
}
```

变量Json：
```

[
    {
        "deviceName": "ModbusTest",
        "rawValue": "12345",
        "value": "12345",
        "changeTime": "2023-03-08T08:42:36.1979048+08:00",
        "collectTime": "2023-03-08T08:46:39.3070467+08:00",
        "quality": 192,
        "readExpressions": null,
        "writeExpressions": null,
        "intervalTime": 1000,
        "otherMethod": null,
        "variableAddress": "40001",
        "name": "test40001",
        "description": null,
        "initialValue": null,
        "protectTypeEnum": 1,
        "dataTypeEnum": 7
    }
]
```
设备Json:
```
[
    {
        "pluginName": "ThingsGateway.Modbus.ModbusTcp",
        "deviceVariablesNum": 1,
        "activeTime": "2023-03-08T08:46:39.2708927+08:00",
        "deviceStatus": 1,
        "deviceOffMsg": "",
        "name": "ModbusTest",
        "description": null,
        "enable": true,
        "createTime": "2023-03-06T17:31:23.0562652",
        "updateTime": "0001-01-01T00:00:00"
    }
]

```


### （二）变量配置
无





